package com.eascs.web.demo.dubbo.action;

import javax.inject.Inject;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.site.controller.BaseRestController;
import com.eascs.site.view.MessageRestResult;
import com.eascs.web.demo.dubbo.api.DubboDemoSeviceRequest;
import com.eascs.web.demo.dubbo.api.DubboDemoSeviceResponse;
import com.eascs.web.demo.dubbo.service.DubboDemoService;

@RestController
public class DubboDemoRestController extends BaseRestController {
	private final Logger logger = LoggerFactory.getLogger(DubboDemoRestController.class);

	@Inject
	private DubboDemoService dubboDemoService;


	@RequestMapping(value = "/demo/dubbo/", method = RequestMethod.GET)
	private MessageRestResult restDemoForm(DubboDemoForm dubboDemoForm) {
		DubboDemoSeviceRequest dubboDemoSeviceRequest = new DubboDemoSeviceRequest();
		dubboDemoSeviceRequest.setName(dubboDemoForm.getName());
		logger.debug("name={}", dubboDemoForm.getName());
		logger.debug("DubboRestController currentThread={}", Thread.currentThread().getId());
		DubboDemoSeviceResponse dubboDemoSeviceResponse = this.dubboDemoService.call(dubboDemoSeviceRequest);
		return MessageRestResult.info(dubboDemoSeviceResponse.getName());
	}

}